package com.group.eams.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group.eams.pojo.dto.PatentCategoryQueryDto;
import com.group.eams.pojo.entity.PatentCategory;
import com.group.eams.service.PatentCategoryService;
import com.group.eams.mapper.PatentCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 恩哲欣
* @description 针对表【patent_category(专利分类表)】的数据库操作Service实现
* @createDate 2024-10-29 16:09:34
*/
@Service
public class PatentCategoryServiceImpl extends ServiceImpl<PatentCategoryMapper, PatentCategory> implements PatentCategoryService{

    @Autowired
    private PatentCategoryMapper patentCategoryMapper;

    /**
     * 根据查询条件查询专利分类
     *
     * @param patentCategoryQueryDto 查询条件
     * @return 专利分类分页列表
     */
    @Override
    public Page<PatentCategory> findByQueryDto(PatentCategoryQueryDto patentCategoryQueryDto) {
        Page<PatentCategory> page = new Page<>(patentCategoryQueryDto.getPage(), patentCategoryQueryDto.getLimit());
        LambdaQueryWrapper<PatentCategory> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(!StrUtil.isEmpty(patentCategoryQueryDto.getName()), PatentCategory::getName, patentCategoryQueryDto.getName())
                .like(!StrUtil.isEmpty(patentCategoryQueryDto.getRemark()), PatentCategory::getRemark, patentCategoryQueryDto.getRemark())
                .eq(patentCategoryQueryDto.getStatus() != null, PatentCategory::getStatus, patentCategoryQueryDto.getStatus());
        return patentCategoryMapper.selectPage(page, wrapper);
    }
}
